#include "gofgame/dungeonkeeper/game/unit/Dwarf.h"

using namespace gofgame::dungeonkeeper::game::unit;

Dwarf::Dwarf(){
	id = 103;
}

Dwarf::~Dwarf(){
}

bool Dwarf::init(){
	bool pRet = false;
	do 
	{
		unitType = UnitType::createById(this->id);
		texture = CCSprite::create(unitType.imageName);
		this->addChild(texture);
		updateState();
		Unit::init();
		pRet = true;
	} while (0);
	return pRet;
}

Dwarf * Dwarf::createByLevel(int lv){
	Dwarf *dwarf = new Dwarf();
	if(dwarf){
		dwarf->lv = lv;
		if( dwarf->init()){
			return dwarf;
		} else {
			return nullptr;
		}
	} else{
		return nullptr;
	}
}

void Dwarf::initData(){
	this->origHp = lv * 20 + unitType.getBaseHP();
	this->currentHp = origHp;
	this->atk = lv * 5 + unitType.getBaseAtk();
	this->def = lv * 5 + unitType.getBaseDef();
	this->speed = unitType.getBaseSpeed();
	this->attkSpeed = unitType.getBaseAttackSpeed();
	this->range = unitType.getBaseRange();
}


void Dwarf::doAI(){

}
